package com.mega.fe.util.client;

import net.minecraft.network.chat.Style;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.FormattedCharSink;

public class FontTextBuilder {
    public static String formattedCharSequenceToString(FormattedCharSequence text) {
        MyFormattedCharSink myFormattedCharSink = new MyFormattedCharSink();
        text.accept(myFormattedCharSink);
        return myFormattedCharSink.getText();
    }

    public static class MyFormattedCharSink implements FormattedCharSink {
        private String text = "";

        @Override
        public boolean accept(int p_13746_, Style p_13747_, int p_13748_) {
            text = text + String.valueOf(Character.toChars(p_13748_));
            return true;
        }

        public String getText() {
            return text;
        }
    }
}
